//
//  ReleaseCaseView.m
//  yonghu
//
//  Created by 浪尖渝力 on 2018/1/15.
//  Copyright © 2018年 com.DJS. All rights reserved.
//

#import "ReleaseCaseView.h"
//#import "selectRegionView.h"
//#import "SelectCaseView.h"
//#import "CaseProgressViewController.h"

@implementation ReleaseCaseView

-(void)creatView{
    
    _scrollView=[UIScrollView new];
    [self addSubview:_scrollView];
    [_scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.left.right.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
    }];
    _scrollView.scrollsToTop =NO;
    
    _scrollView.showsVerticalScrollIndicator = FALSE;
    _scrollView.showsHorizontalScrollIndicator = FALSE;
    _scrollView.bounces = NO;
    
    

    if (@available(iOS 11.0, *)) {
        self.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    } else {
        self.viewController.automaticallyAdjustsScrollViewInsets = NO;
    }
    
    self.backgroundColor=_LightGrey;
    UIView *topView=[UIView new];
    [_scrollView addSubview: topView];
    [topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.mas_equalTo(NAV_HEIGHT);
        make.width.mas_equalTo(_mainW);
        make.height.mas_equalTo(NAV_HEIGHT+15);
    }];
    topView.backgroundColor=[UIColor whiteColor];
    [self creatTopView:topView];
    
    UIView *NeiRongView=[UIView new];
    [_scrollView addSubview:NeiRongView];
    [NeiRongView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(topView).mas_equalTo(5);
        make.right.mas_equalTo(topView).mas_equalTo(-5);
        make.height.mas_equalTo(340);
        make.top.mas_equalTo(topView.mas_bottom).mas_equalTo(10);
    }];
    NeiRongView.backgroundColor=[UIColor whiteColor];
    [self creatNeiRong:NeiRongView];
    [self creatAnswerView];
    
}
-(void)creatTopView:(UIView *)topView{
    UIImageView *imgaeViwe=[UIImageView new];
    [topView addSubview:imgaeViwe];
    [imgaeViwe mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.centerY.mas_equalTo(0);
        make.height.width.mas_equalTo(50);
    }];
    imgaeViwe.layer.cornerRadius=25;
    imgaeViwe.layer.masksToBounds=YES;
    NSString *user_icon=[_dic objectForKey:@"user_icon"];
    NSURL *url=[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",_addressUrl,user_icon]];
    [imgaeViwe sd_setImageWithURL:url];
    
    UILabel *phoneLabel=[UILabel new];
    [topView addSubview:phoneLabel];
    [phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(imgaeViwe.mas_right).mas_equalTo(10);
        make.centerY.mas_equalTo(0);
    }];
    phoneLabel.text=[_dic objectForKey:@"user_nickname"];
    phoneLabel.font=[UIFont systemFontOfSize:18];
    phoneLabel.textColor=ColorWithRGB(49, 49, 49);
    
    UIImageView *imageView2=[UIImageView new];
    [topView addSubview:imageView2];
    [imageView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-15);
        make.centerY.mas_equalTo(0);
        make.height.mas_equalTo(40);
        make.width.mas_equalTo(65);
    }];
    NSNumber *litigation_status=[_dic objectForKey:@"litigation_send_status"];
    if (litigation_status.integerValue==1) {
        imageView2.image=[UIImage imageNamed:@"待接受"];
    }
    if (litigation_status.integerValue==2) {
        imageView2.image=[UIImage imageNamed:@"进行中"];
    }
    if (litigation_status.integerValue==3) {
        imageView2.image=[UIImage imageNamed:@"已完成"];
    }
}
-(void)creatNeiRong:(UIView *)view{
    view.layer.cornerRadius=5;
    UIView *xianView=[UIView new];
    [view addSubview:xianView];
    [xianView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.width.mas_equalTo(6);
        make.height.mas_equalTo(22);
        make.top.mas_equalTo(15);
    }];
    xianView.backgroundColor=_backgroundColor;
    
    UILabel *label1=[UILabel new];
    [view addSubview:label1];
    [label1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(xianView.mas_right).mas_equalTo(10);
        make.centerY.mas_equalTo(xianView);
    }];
    label1.text=@"案件信息";
    label1.textColor=ColorWithRGB(49, 49, 49);
    label1.font=[UIFont systemFontOfSize:16];
    
    UILabel *label2=[UILabel new];
    [view addSubview:label2];
    [label2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(xianView);
        make.top.mas_equalTo(xianView.mas_bottom).mas_equalTo(20);
    }];
    label2.text=@"案件类型";
    label2.textColor=ColorWithRGB(49, 49, 49);
    label2.font=[UIFont systemFontOfSize:16];
    
    UILabel *label3=[UILabel new];
    [view addSubview:label3];
    [label3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-15);
        make.centerY.mas_equalTo(label2);
    }];
    label3.text=[_dic objectForKey:@"litigation_ct_name"];
    label3.textColor=ColorWithRGB(79, 79, 79 );
    label3.font=[UIFont systemFontOfSize:16];
    
    UIView *XianView1=[UIView new];
    [view addSubview:XianView1];
    [XianView1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(label3.mas_bottom).mas_equalTo(15);
        make.height.mas_equalTo(1);
    }];
    XianView1.backgroundColor=_LightGrey;
    

    
    UILabel *label4=[UILabel new];
    [view addSubview:label4];
    [label4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(xianView);
        make.top.mas_equalTo(XianView1.mas_bottom).mas_equalTo(20);
    }];
    label4.text=@"委托人称呼";
    label4.textColor=ColorWithRGB(49, 49, 49);
    label4.font=[UIFont systemFontOfSize:16];
    
    UILabel *label5=[UILabel new];
    [view addSubview:label5];
    [label5 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-15);
        make.centerY.mas_equalTo(label4);
    }];
    label5.text=[_dic objectForKey:@"litigation_party_name"];
    label5.textColor=ColorWithRGB(79, 79, 79 );
    label5.font=[UIFont systemFontOfSize:16];
    
    UIView *XianView2=[UIView new];
    [view addSubview:XianView2];
    [XianView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(label4.mas_bottom).mas_equalTo(15);
        make.height.mas_equalTo(1);
    }];
    XianView2.backgroundColor=_LightGrey;
    
    
    UILabel *label6=[UILabel new];
    [view addSubview:label6];
    [label6 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(xianView);
        make.top.mas_equalTo(XianView2.mas_bottom).mas_equalTo(20);
    }];
    label6.text=@"委托地区";
    label6.textColor=ColorWithRGB(49, 49, 49);
    label6.font=[UIFont systemFontOfSize:16];
    
    UILabel *label7=[UILabel new];
    [view addSubview:label7];
    [label7 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-15);
        make.centerY.mas_equalTo(label6);
    }];
    label7.text=[_dic objectForKey:@"litigation_city_name"];
    label7.textColor=ColorWithRGB(79, 79, 79 );
    label7.font=[UIFont systemFontOfSize:16];
    
    UIView *XianView3=[UIView new];
    [view addSubview:XianView3];
    [XianView3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(label6.mas_bottom).mas_equalTo(15);
        make.height.mas_equalTo(1);
    }];
    XianView3.backgroundColor=_LightGrey;
    
    
    UILabel *label8=[UILabel new];
    [view addSubview:label8];
    [label8 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(xianView);
        make.top.mas_equalTo(XianView3.mas_bottom).mas_equalTo(20);
    }];
    label8.text=@"委托时间";
    label8.textColor=ColorWithRGB(49, 49, 49);
    label8.font=[UIFont systemFontOfSize:16];
    
    UILabel *label9=[UILabel new];
    [view addSubview:label9];
    [label9 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-15);
        make.centerY.mas_equalTo(label8);
    }];
    NSNumber *litigation_time=[_dic objectForKey:@"litigation_time"];
    label9.text=[ZQTools changeTimeCuo:@"yyyy-MM-dd HH:mm" :[NSString stringWithFormat:@"%@",litigation_time]];
    label9.textColor=ColorWithRGB(79, 79, 79 );
    label9.font=[UIFont systemFontOfSize:16];
    
    UIView *XianView4=[UIView new];
    [view addSubview:XianView4];
    [XianView4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(label8.mas_bottom).mas_equalTo(15);
        make.height.mas_equalTo(1);
    }];
    XianView4.backgroundColor=_LightGrey;
    
    
    UILabel *label10=[UILabel new];
    [view addSubview:label10];
    [label10 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(xianView);
        make.top.mas_equalTo(XianView4.mas_bottom).mas_equalTo(20);
    }];
    label10.text=@"委托金额";
    label10.textColor=ColorWithRGB(49, 49, 49);
    label10.font=[UIFont systemFontOfSize:16];
    
    UILabel *label11=[UILabel new];
    [view addSubview:label11];
    [label11 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-15);
        make.centerY.mas_equalTo(label10);
    }];
    
    NSNumber *litigation_money=[_dic objectForKey:@"litigation_money"];
    if ([litigation_money isKindOfClass:[NSNull class]]) {
        litigation_money=@0;
    }
    label11.text=[NSString stringWithFormat:@"%@元",litigation_money];
    label11.textColor=ColorWithRGB(79, 79, 79 );
    label11.font=[UIFont systemFontOfSize:16];
    
    UIView *XianView5=[UIView new];
    [view addSubview:XianView5];
    [XianView5 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(label10.mas_bottom).mas_equalTo(15);
        make.height.mas_equalTo(1);
    }];
    XianView5.backgroundColor=_LightGrey;
}
-(void)creatAnswerView{
    
    [_answerView removeFromSuperview];
    [_tishiLabel removeFromSuperview];
    [_shangChuanView removeFromSuperview];
    
    _answerView=[UIView new];
    [_scrollView addSubview:_answerView];
 
    
    CGFloat height=45;
    NSArray *answerArr=[_dic objectForKey:@"answer"];
    int index;
    if (answerArr.count>3) {
        index=2;
    }
    else{
        index=(int)answerArr.count;
    }
    for (int i=0; i<index; i++) {
        NSDictionary *dic=answerArr[i];
        NSString *answer_problem=[dic objectForKey:@"answer_problem"];
        NSString *answer_content=[dic objectForKey:@"answer_content"];
        if ([answer_problem rangeOfString:@"？"].location != NSNotFound) {
            answer_problem=[answer_problem substringToIndex:answer_problem.length-1];
        }
        NSString *typeStr=[NSString stringWithFormat:@"%@:%@",answer_problem,answer_content];
        CGSize size=[ZQTools getNSStringSize:typeStr andViewWight:_mainW-40 andFont:16];
        
        UILabel *label=[UILabel new];
        [_answerView addSubview:label];
        [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(15);
            make.right.mas_equalTo(-15);
            make.top.mas_equalTo(height);
            make.height.mas_equalTo(size.height);
        }];
        label.numberOfLines=0;
        label.text=typeStr;
        label.textColor=ColorWithRGB(49, 49, 49);
        
        height=height+size.height+20;
    }
    if (answerArr.count>3) {
        UIImageView *imageView2=[UIImageView new];
        [_answerView addSubview:imageView2];
        [imageView2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.mas_equalTo(0);
            make.bottom.mas_equalTo(-5);
            make.width.mas_equalTo(22);
            make.height.mas_equalTo(14);
        }];
        imageView2.userInteractionEnabled=YES;
        imageView2.image=[UIImage imageNamed:@"展开"];
        imageView2.userInteractionEnabled=YES;
        UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(creatAnswerView2)];
        [_answerView addGestureRecognizer:tapGesture];

       height=height+40;
    }
    
    [_answerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0).mas_equalTo(5);
        make.width.mas_equalTo(_mainW);
        make.height.mas_equalTo(height);
        make.top.mas_equalTo(504);
    }];
    _answerView.backgroundColor=[UIColor whiteColor];
    
    _scrollView.contentSize = CGSizeMake(0, 504+height+60);

    NSNumber *itigation_status=[_dic objectForKey:@"litigation_send_status"];
    if (itigation_status.integerValue==1) {
        _btn1=[UIButton new];
        [self addSubview:_btn1];
        [_btn1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(0);
            make.width.mas_equalTo(_mainW/2);
            make.height.mas_equalTo(50);
            make.bottom.mas_equalTo(0);
        }];
        [_btn1 setTitle:@"接受" forState:0];
        [_btn1 setTitleColor:[UIColor whiteColor] forState:0];
        _btn1.backgroundColor=ColorWithRGB(183, 157, 108);
        [_btn1 addTarget:self action:@selector(jieShou:) forControlEvents:UIControlEventTouchUpInside];
        
        _btn2=[UIButton new];
        [self addSubview:_btn2];
        [_btn2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(_btn1.mas_right);
            make.width.mas_equalTo(_mainW/2);
            make.height.mas_equalTo(50);
            make.bottom.mas_equalTo(0);
        }];
        [_btn2 setTitle:@"拒绝" forState:0];
        [_btn2 setTitleColor:[UIColor whiteColor] forState:0];
        _btn2.backgroundColor=ColorWithRGB(93, 148, 172);
        [_btn2 addTarget:self action:@selector(jieShou2:) forControlEvents:UIControlEventTouchUpInside];
    }
    
    NSString *sl_file=[_dic objectForKey:@"sl_file"];
    if ([ZQTools charIsNil:sl_file]) {
        _tishiLabel=[UILabel new];
        [_scrollView addSubview:_tishiLabel];
        [_tishiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(_answerView.mas_left).mas_equalTo(10);
            make.top.mas_equalTo(_answerView.mas_bottom).mas_equalTo(20);
        }];
        _tishiLabel.textColor=ColorWithRGB(77, 172, 221);
        _tishiLabel.text=@"提示请在PC端上传案件资料";
        _tishiLabel.font=[UIFont systemFontOfSize:15];
    }
    else{
        NSNumber *sl_check=[_dic objectForKey:@"sl_check"];
        _shangChuanView=[UIView new];
        [_scrollView addSubview:_shangChuanView];
        [_shangChuanView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.mas_equalTo(_answerView);
            make.top.mas_equalTo(_answerView.mas_bottom).mas_equalTo(10);
            make.height.mas_equalTo(110);
        }];
        _shangChuanView.backgroundColor=[UIColor whiteColor];
        
        UIView *xianView=[UIView new];
        [_shangChuanView addSubview:xianView];
        [xianView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(15);
            make.top.mas_equalTo(15);
            make.width.mas_equalTo(5);
            make.height.mas_equalTo(22);
        }];
        xianView.backgroundColor=_backgroundColor;
        
        UILabel *label1=[UILabel new];
        [_shangChuanView addSubview:label1];
        [label1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(xianView.mas_right).mas_equalTo(10);
            make.centerY.mas_equalTo(xianView);
        }];
        label1.text=@"上传的资料";
        label1.textColor=ColorWithRGB(49, 49, 49);
        label1.font=[UIFont systemFontOfSize:16];
        
        
        
        
        UIImageView *SCimgaView=[UIImageView new];
        [_shangChuanView addSubview:SCimgaView];
        [SCimgaView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(xianView);
            make.top.mas_equalTo(xianView.mas_bottom).mas_equalTo(20);
            make.width.height.mas_equalTo(35);
        }];
        SCimgaView.image=[UIImage imageNamed:@"律师函"];
        
        
        
        
        UILabel *label2=[UILabel new];
        [_shangChuanView addSubview:label2];
        [label2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(SCimgaView.mas_right).mas_equalTo(20);
            make.centerY.mas_equalTo(SCimgaView);
        }];
        label2.text=@"立即下载";
        label2.font=[UIFont systemFontOfSize:14];
        label2.textColor=_backgroundColor;
        
        _scrollView.contentSize = CGSizeMake(0, 614+height+60);
        
        
        
        UIView *xiaZaiView=[UIView new];
        [_shangChuanView addSubview:xiaZaiView];
        [xiaZaiView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(0);
            make.top.mas_equalTo(SCimgaView.mas_top).mas_equalTo(-5);
            make.bottom.mas_equalTo(SCimgaView.mas_bottom).mas_equalTo(5);
            make.right.mas_equalTo(label2.mas_right);
        }];
        
        UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(xiazai)];
        [xiaZaiView addGestureRecognizer:tapGesture];
        
        
        
        UILabel *lable3=[UILabel new];
        [_shangChuanView addSubview:lable3];
        [lable3 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-25);
            make.centerY.mas_equalTo(label2);
        }];
        lable3.textColor=[UIColor redColor];
        lable3.font=[UIFont systemFontOfSize:14];
        if (sl_check.integerValue==0) {
            lable3.text=@"待审核";
        }if (sl_check.integerValue==1) {
            lable3.text=@"待接受";
        }if (sl_check.integerValue==2) {
            lable3.text=@"审核未通过";
            _tishiLabel=[UILabel new];
            [_scrollView addSubview:_tishiLabel];
            [_tishiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(_answerView.mas_left).mas_equalTo(10);
                make.top.mas_equalTo(_shangChuanView.mas_bottom).mas_equalTo(20);
            }];
            _tishiLabel.textColor=ColorWithRGB(77, 172, 221);
            _tishiLabel.text=@"提示请在PC端重新上传案件资料";
            _tishiLabel.font=[UIFont systemFontOfSize:15];
        
        }if (sl_check.integerValue==3) {
            lable3.text=@"被拒绝";
            _tishiLabel=[UILabel new];
            [_scrollView addSubview:_tishiLabel];
            [_tishiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(_answerView.mas_left).mas_equalTo(10);
                make.top.mas_equalTo(_shangChuanView.mas_bottom).mas_equalTo(20);
            }];
            _tishiLabel.textColor=ColorWithRGB(77, 172, 221);
            _tishiLabel.text=@"提示请在PC端重新上传案件资料";
            _tishiLabel.font=[UIFont systemFontOfSize:15];
        
        }
        if (sl_check.integerValue==4) {
            UIImageView *imageView2=[UIImageView new];
            [_shangChuanView addSubview:imageView2];
            [imageView2 mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.mas_equalTo(-15);
                make.centerY.mas_equalTo(0);
                make.height.mas_equalTo(40);
                make.width.mas_equalTo(65);
            }];
            imageView2.image=[UIImage imageNamed:@"已采纳"];
        }
    }

}
-(void)creatAnswerView2{
    
    [_answerView removeFromSuperview];
    [_tishiLabel removeFromSuperview];
    CGFloat height=15;
    NSArray *answerArr=[_dic objectForKey:@"answer"];
    int index;
    
    _answerView=[UIView new];
    [_scrollView addSubview:_answerView];
    
    index=(int)answerArr.count;
    
    for (int i=0; i<answerArr.count; i++) {
        NSDictionary *dic=answerArr[i];
        NSString *answer_problem=[dic objectForKey:@"answer_problem"];
        NSString *answer_content=[dic objectForKey:@"answer_content"];
        if ([answer_problem rangeOfString:@"？"].location != NSNotFound) {
            answer_problem=[answer_problem substringToIndex:answer_problem.length-1];
        }
        NSString *typeStr=[NSString stringWithFormat:@"%@:%@",answer_problem,answer_content];
        CGSize size=[ZQTools getNSStringSize:typeStr andViewWight:_mainW-40 andFont:16];
        
        UILabel *label=[UILabel new];
        [_answerView addSubview:label];
        [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(15);
            make.right.mas_equalTo(-15);
            make.top.mas_equalTo(height);
            make.height.mas_equalTo(size.height);
        }];
        label.numberOfLines=0;
        label.text=typeStr;
        label.textColor=ColorWithRGB(49, 49, 49);
        
        height=height+size.height+20;
    }
    UIImageView *imageView2=[UIImageView new];
    [_answerView addSubview:imageView2];
    [imageView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.bottom.mas_equalTo(-5);
        make.width.mas_equalTo(22);
        make.height.mas_equalTo(14);
    }];
    imageView2.image=[UIImage imageNamed:@"收起"];
    imageView2.userInteractionEnabled=YES;
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(creatAnswerView)];
    [_answerView addGestureRecognizer:tapGesture];
    
    
    [_answerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0).mas_equalTo(5);
        make.width.mas_equalTo(_mainW);
        make.height.mas_equalTo(height+40);
        make.top.mas_equalTo(504);
    }];
    _answerView.backgroundColor=[UIColor whiteColor];
    
    _scrollView.contentSize = CGSizeMake(0, 524+height+40+50);

    
    NSNumber *itigation_status=[_dic objectForKey:@"litigation_send_status"];
    if (itigation_status.integerValue==1) {
        _btn1=[UIButton new];
        [self addSubview:_btn1];
        [_btn1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(0);
            make.width.mas_equalTo(_mainW/2);
            make.height.mas_equalTo(50);
            make.bottom.mas_equalTo(0);
        }];
        [_btn1 setTitle:@"接受" forState:0];
        [_btn1 setTitleColor:[UIColor whiteColor] forState:0];
        _btn1.backgroundColor=ColorWithRGB(183, 157, 108);
        [_btn1 addTarget:self action:@selector(jieShou:) forControlEvents:UIControlEventTouchUpInside];
        
        _btn2=[UIButton new];
        [self addSubview:_btn2];
        [_btn2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(_btn1.mas_right);
            make.width.mas_equalTo(_mainW/2);
            make.height.mas_equalTo(50);
            make.bottom.mas_equalTo(0);
        }];
        [_btn2 setTitle:@"拒绝" forState:0];
        [_btn2 setTitleColor:[UIColor whiteColor] forState:0];
        _btn2.backgroundColor=ColorWithRGB(93, 148, 172);
        [_btn2 addTarget:self action:@selector(jieShou2:) forControlEvents:UIControlEventTouchUpInside];
    }
    else{
        
        NSString *sl_file=[_dic objectForKey:@"sl_file"];
        if ([ZQTools charIsNil:sl_file]) {
            _tishiLabel=[UILabel new];
            [_scrollView addSubview:_tishiLabel];
            [_tishiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(_answerView.mas_left).mas_equalTo(10);
                make.top.mas_equalTo(_answerView.mas_bottom).mas_equalTo(20);
            }];
            _tishiLabel.textColor=ColorWithRGB(77, 172, 221);
            _tishiLabel.text=@"提示请在PC端重新上传案件资料";
            _tishiLabel.font=[UIFont systemFontOfSize:15];
        }
        else{
            NSNumber *sl_check=[_dic objectForKey:@"sl_check"];
            _shangChuanView=[UIView new];
            [_scrollView addSubview:_shangChuanView];
            [_shangChuanView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.right.mas_equalTo(_answerView);
                make.top.mas_equalTo(_answerView.mas_bottom).mas_equalTo(10);
                make.height.mas_equalTo(110);
            }];
            _shangChuanView.backgroundColor=[UIColor whiteColor];
            
            UIView *xianView=[UIView new];
            [_shangChuanView addSubview:xianView];
            [xianView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(15);
                make.top.mas_equalTo(15);
                make.width.mas_equalTo(5);
                make.height.mas_equalTo(22);
            }];
            xianView.backgroundColor=_backgroundColor;
            
            UILabel *label1=[UILabel new];
            [_shangChuanView addSubview:label1];
            [label1 mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(xianView.mas_right).mas_equalTo(10);
                make.centerY.mas_equalTo(xianView);
            }];
            label1.text=@"上传的资料";
            label1.textColor=ColorWithRGB(49, 49, 49);
            label1.font=[UIFont systemFontOfSize:16];
            
            
            UIImageView *SCimgaView=[UIImageView new];
            [_shangChuanView addSubview:SCimgaView];
            [SCimgaView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(xianView);
                make.top.mas_equalTo(xianView.mas_bottom).mas_equalTo(20);
                make.width.height.mas_equalTo(35);
            }];
            SCimgaView.image=[UIImage imageNamed:@"律师函"];
            
            UILabel *label2=[UILabel new];
            [_shangChuanView addSubview:label2];
            [label2 mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(SCimgaView.mas_right).mas_equalTo(20);
                make.centerY.mas_equalTo(SCimgaView);
            }];
            label2.text=@"执行方案";
            label2.font=[UIFont systemFontOfSize:14];
            label2.textColor=_backgroundColor;
            
            _scrollView.contentSize = CGSizeMake(0, 610+height+60);
            
            UILabel *lable3=[UILabel new];
            [_shangChuanView addSubview:lable3];
            [lable3 mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.mas_equalTo(-25);
                make.centerY.mas_equalTo(label2);
            }];
            lable3.textColor=[UIColor redColor];
            lable3.font=[UIFont systemFontOfSize:14];
            if (sl_check.integerValue==0) {
                lable3.text=@"待审核";
            }if (sl_check.integerValue==1) {
                lable3.text=@"待接受";
            }if (sl_check.integerValue==2) {
                lable3.text=@"审核未通过";
                _tishiLabel=[UILabel new];
                [_scrollView addSubview:_tishiLabel];
                [_tishiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.mas_equalTo(_answerView.mas_left).mas_equalTo(10);
                    make.top.mas_equalTo(_answerView.mas_bottom).mas_equalTo(20);
                }];
                _tishiLabel.textColor=ColorWithRGB(77, 172, 221);
                _tishiLabel.text=@"提示请在PC端重新上传案件资料";
                _tishiLabel.font=[UIFont systemFontOfSize:15];
                
            }if (sl_check.integerValue==3) {
                lable3.text=@"被拒绝";
                _tishiLabel=[UILabel new];
                [_scrollView addSubview:_tishiLabel];
                [_tishiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.mas_equalTo(_answerView.mas_left).mas_equalTo(10);
                    make.top.mas_equalTo(_answerView.mas_bottom).mas_equalTo(20);
                }];
                _tishiLabel.textColor=ColorWithRGB(77, 172, 221);
                _tishiLabel.text=@"提示请在PC端重新上传案件资料";
                _tishiLabel.font=[UIFont systemFontOfSize:15];
                
            }
            if (sl_check.integerValue==4) {
                UIImageView *imageView2=[UIImageView new];
                [_shangChuanView addSubview:imageView2];
                [imageView2 mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.right.mas_equalTo(-15);
                    make.centerY.mas_equalTo(0);
                    make.height.mas_equalTo(40);
                    make.width.mas_equalTo(65);
                }];
                imageView2.image=[UIImage imageNamed:@"已采纳"];
            }
            
        }
        
        
    }
    
    
}

-(IBAction)jieShou:(id)sender{
    
    NSNumber *assign_id=[_dic objectForKey:@"assign_id"];
    NSNumber *consult_id=[_dic objectForKey:@"litigation_id"];
    NSDictionary *userDic = [NSKeyedUnarchiver unarchiveObjectWithFile:_userModelFile];
    NSString *token=[userDic objectForKey:@"token"];
    NSNumber *waiter_id1=[userDic objectForKey:@"waiter_id"];
    NSString *waiter_id=[NSString stringWithFormat:@"%@",waiter_id1];
    
    NSDictionary *dic=[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%@",assign_id],@"assign_id",@"1",@"action",[NSString stringWithFormat:@"%@",consult_id],@"litigation_id",token,@"token",waiter_id,@"waiter_id",@"1",@"user_role", nil];
    [ZQTools AFNPostDataUrl:@"waiter/Litigation/accept_litigation" Dict:dic andTableView:nil andViewController:self.viewController andSuccessBlock:^(id responseObject) {
        [_btn1 removeFromSuperview];
        [_btn2 removeFromSuperview];
        _customSelectedBlock(1);
        
    } anderrorBlock:nil];
}

-(IBAction)jieShou2:(id)sender{
    
    NSNumber *assign_id=[_dic objectForKey:@"assign_id"];
    NSNumber *consult_id=[_dic objectForKey:@"litigation_id"];
    NSDictionary *userDic = [NSKeyedUnarchiver unarchiveObjectWithFile:_userModelFile];
    NSString *token=[userDic objectForKey:@"token"];
    NSNumber *waiter_id1=[userDic objectForKey:@"waiter_id"];
    NSString *waiter_id=[NSString stringWithFormat:@"%@",waiter_id1];
    
    NSDictionary *dic=[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%@",assign_id],@"assign_id",@"2",@"action",[NSString stringWithFormat:@"%@",consult_id],@"litigation_id",token,@"token",waiter_id,@"waiter_id",@"2",@"user_role", nil];
    [ZQTools AFNPostDataUrl:@"waiter/Litigation/accept_litigation" Dict:dic andTableView:nil andViewController:self.viewController andSuccessBlock:^(id responseObject) {
        [_btn1 removeFromSuperview];
        [_btn2 removeFromSuperview];
        _customSelectedBlock(2);
        
    } anderrorBlock:nil];
}

-(void)xiazai {
    
    
    
    NSString *str=[_dic objectForKey:@"sl_file"];
    NSString *cuo=[ZQTools NSDateToTimeCuo:[NSDate new]];
    
    NSString * time=[ZQTools changeTimeCuo:@"yyyy-MM-dd":cuo];
    NSString * time2=[ZQTools changeTimeCuo:@"yyyy-MM-dd-HH:mm:ss":cuo];
    
    
    NSMutableDictionary  *dic=[NSMutableDictionary dictionaryWithCapacity:0];
    
    // 要下载文件的url
    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@",_addressUrl,str]];
    
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    NSURLSessionDownloadTask *task = [manager downloadTaskWithRequest:request progress:^(NSProgress * _Nonnull downloadProgress) {
        
        double daxiao=downloadProgress.totalUnitCount/1024;
        [dic setObject:[NSString stringWithFormat:@"%.2fKB",daxiao] forKey:@"size"];
        
    } destination:^NSURL * _Nonnull(NSURL * _Nonnull targetPath, NSURLResponse * _Nonnull response) {
        
        NSURL *documentsDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil];
        NSLog(@"file = %@",targetPath);
        [dic setObject:[NSString stringWithFormat:@"%@_%@",time2,[response suggestedFilename]] forKey:@"filePath"];
        return [documentsDirectoryURL URLByAppendingPathComponent:[NSString stringWithFormat:@"%@_%@",time2,[response suggestedFilename]]];
        
        
        
    } completionHandler:^(NSURLResponse * _Nonnull response, NSURL * _Nullable filePath, NSError * _Nullable error) {
        
        [MBProgressHUD hideHUDForView:self animated:YES];
        [dic setObject:@"执行方案" forKey:@"title"];
        [dic setObject:time forKey:@"time"];
        
        [ZQTools svpInfo:@"下载成功，请在我的下载中查看"];
        NSArray *xiaArr = [NSKeyedUnarchiver unarchiveObjectWithFile:_xiaZai];
        
        NSMutableArray *typeArr=[NSMutableArray arrayWithArray:xiaArr];
        [typeArr addObject:dic];
        [NSKeyedArchiver archiveRootObject:typeArr toFile:_xiaZai];
        
        
    }];
    [task resume];//开始下载 要不然不会进行下载的
    
}
@end
